class SelectLevel extends eui.Component implements eui.UIComponent {
	public constructor() {
		super();
	}

	protected partAdded(partName: string, instance: any): void {
		super.partAdded(partName, instance);
	}


	protected childrenCreated(): void {
		super.childrenCreated();
		this.init();
	}


	public btn_back: eui.Image;

	public list_item: eui.List;
	public static Source_arr;
	private init() {


		this.btn_back.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
			SceneManager.Instance.switchScene(SceneManager.Instance.chooseMode);
		}, this)
		var source_arr = [];
		var levelGroupData: [{ id: number, src: string, position: [{ x: number, y: number }], star: Array<number>, starNum: number, isCrown: boolean }] = RES.getRes("LevelGroupData_json").row;
		let GroupNum: number;
		if (levelGroupData.length % 20 == 0) {
			GroupNum = Math.floor(levelGroupData.length / 20);
		} else {
			GroupNum = Math.floor(levelGroupData.length / 20) + 1;
		}
		for (var i = 0; i < GroupNum; i++) {
			source_arr[i] = { label: `${i * 20 + 1}-${i * 20 + 20}`, arr: [] };
			for (let j = 0; j < levelGroupData.length; j++) {
				if (Math.floor(j / 20) == i) {
					source_arr[i].arr.push(levelGroupData[j])
				}
			}
		}
		SelectLevel.Source_arr = source_arr;
		// this.list_item.
		
		this.list_item.dataProvider = new eui.ArrayCollection(source_arr);
		this.list_item.itemRenderer = LevelGroup;
	}

	public static getSourceData() {
		return SelectLevel.Source_arr;
	}




}